package com.cooper.util;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * 
* @Description: 
* @version: v1.0.0
* @author: tianlg
* @date: Jan 20, 2015 3:25:54 PM
*
* Modification History:
* Date         Author          Version            Description
*---------------------------------------------------------*
* Jan 20, 2015      tianlg          v1.0.0
 */
public class IOUtils extends org.apache.commons.io.IOUtils {

	public static String readTxtFileToString(String filepath){
		StringBuffer buffer = new StringBuffer();
		FileReader fileReader = null;
		BufferedReader reader = null;
		try {
			fileReader = new FileReader(filepath);
			reader = new BufferedReader(fileReader);
			String strLine = "";
			while(null != (strLine = reader.readLine())){
				buffer.append(strLine).append("\r\n");
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e){
			e.printStackTrace();
		} finally{
			try {
				if(null != reader){
					reader.close();
					reader = null;
				}
				if(null != fileReader){
					fileReader.close();
					fileReader = null;
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return buffer.toString();
	}
}
